//
//  YSRegistertzjgViewController.m
//  YSZC
//
//  Created by 张斌 on 16/4/12.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "YSRegistertzjgViewController.h"

#import "UIView+CZFrame.h"








#import "YSTextfield.h"







#import "YSDoViewManager.h"








@interface YSRegistertzjgViewController ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIView *tipview;
@property (weak, nonatomic) IBOutlet UIButton *tzrbtn;
@property (weak, nonatomic) IBOutlet UIButton *tzjgbtn;
@property (weak, nonatomic) IBOutlet UIView *userview;
@property (weak, nonatomic) IBOutlet UIView *phoneview;
@property (weak, nonatomic) IBOutlet UIView *checkview;
@property (weak, nonatomic) IBOutlet UIView *mailview;
@property (weak, nonatomic) IBOutlet UIView *passview1;
@property (weak, nonatomic) IBOutlet UIView *passview2;
@property (weak, nonatomic) IBOutlet UIButton *getcodebtn;
@property (weak, nonatomic) IBOutlet UIButton *registerbtn;

@property (weak, nonatomic) IBOutlet UIButton *protcolbtn;
@property (weak, nonatomic) IBOutlet UITextField *user_tx;

@property (weak, nonatomic) IBOutlet UITextField *phone_tx;
@property (weak, nonatomic) IBOutlet UIView *jgView;

@property (weak, nonatomic) IBOutlet YSTextfield *check_tx;

@property (weak, nonatomic) IBOutlet YSTextfield *mail_tx;

@property (weak, nonatomic) IBOutlet YSTextfield *pass_tx1;
@property (weak, nonatomic) IBOutlet YSTextfield *pass_tx2;
@property (weak, nonatomic) IBOutlet UIButton *selectjgbtn;
@property (strong, nonatomic) UIView* selectview;
@end

@implementation YSRegistertzjgViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.pass_tx1.delegate = self;
    self.pass_tx2.delegate = self;
    
    self.tzjgbtn.selected = YES;
    
    self.title = @"投资机构注册";
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    [[YSDoViewManager sharedmanager] settoyuanWithview:@[self.userview,self.phoneview,self.checkview,self.mailview,self.passview1,self.passview2,self.getcodebtn,self.registerbtn]];
}
// 下拉菜单
- (IBAction)selectjgbtnclick:(UIButton *)sender {
    
}

- (IBAction)closebtnclick:(id)sender {
    self.tipview.hidden = YES;
}
- (IBAction)tzrbtnclick:(id)sender {
    self.tzrbtn.selected = !self.tzrbtn.selected;
}
- (IBAction)tzjgbtnclick:(id)sender {
    self.tzjgbtn.selected = !self.tzjgbtn.selected;
}
- (IBAction)protcolbtnclick:(id)sender {
    self.protcolbtn.selected = !self.protcolbtn.selected;
    
}

//

- (IBAction)registerbtnclick:(id)sender {
    
}
- (IBAction)getcodebtnclick:(id)sender {
    
}
// 跟随键盘
-(void)changeViewFrame:(NSNotification *)noti{
    //1.获取 结束时候的Frame即可
    //    NSLog(@"%@",noti);
    //2.获取结束的Frame
    CGRect endRect =  [noti.userInfo[@"UIKeyboardFrameEndUserInfoKey"]CGRectValue];
    //拿 结束的Frame中的y值 跟界面的高度做减法 得到 最终 控制器的View 的y值
    CGFloat endY = endRect.origin.y-self.view.frame.size.height+120;
    
    //设置给控制器的View的Frame即可
    CGRect oldFrame=self.view.frame;
    if (endY>0) {
        endY = 0;
    }
    oldFrame.origin.y=endY;
    
    
    self.view.frame=oldFrame;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    if ([textField isKindOfClass:[YSTextfield class]]) {
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(changeViewFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
        
    }else{
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
    }
    
}

- (void)textFieldDidEndEditing:(UITextField *)textField{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
    
}


@end
